#include<bits/stdc++.h>
using namespace std;
long long n,js;
long long g[200010];
struct aal
{
	long long bh;
	long long sg;
	long long qs;
}a[200010];
int fi(int x)
{
	int k=x-1;
	for(int i=x-1;;i--)
	{
		if(!a[i].qs)
		{
			continue;
		}
		else
		{
			k=i;
			break;
		}
	}
	return k;
}
int main()
{
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i].sg);
		a[i].bh=i;
		a[i].qs=1;
	}
	a[0].sg=2;
	bool b=true;
	while(b)
	{
		b=false;
		for(int i=n;i>=1;i--)
		{
			if(!a[i].qs)
			{
				continue;
			}
			if(a[i].sg!=a[fi(i)].sg)
			{
				b=true;
				g[++js]=a[i].bh;
				
			}
		}
		for(int i=js;i>=1;i--)
		{
			printf("%lld ",g[i]);
			a[g[i]].qs=0;
		}
		js=0;
		memset(g,0,sizeof(g));
		printf("\n");
	}
	return 0;
}
